/** ** */

$(document).ready(function() {
	$(".input-daterange").datepicker({
		keyboardNavigation : !1,
		forceParse : !1,
		autoclose : !0,
		onSelect : selectDate
	}).on('changeDate', selectDate);

	$("#start_time").datepicker({
		dateFormat : "yy-mm-dd",
		minDate : new Date()
	});
});

// 点击日期回调事件
function selectDate(ev) {
	updateDayAndMoney();
}

function showPrice(obj) {
	$("#positionprice").html(
			$('#position_id option:selected').attr("data_price"));
	updateDayAndMoney();
}

// 更新投放天数金额等
function updateDayAndMoney() {
	var positionprice = $("#positionprice").html();
	var start_time = $("#start_time").val();
	var end_time = $("#end_time").val();
	var days = parseInt(getDays(start_time, end_time)) + 1;
	var moneysum = days * parseFloat(positionprice)
	$("#daynum").html(days);
	if (!isNaN(moneysum)) {
		$("#total_amount").val(moneysum);
	}

}

function getDays(strDateStart, strDateEnd) {
	var strDateS = new Date(strDateStart.replace(/-/g, "/"));
	var strDateE = new Date(strDateEnd.replace(/-/g, "/"));
	var iDays = parseInt(Math.abs(strDateS - strDateE) / 1000 / 60 / 60 / 24)// 把相差的毫秒数转换为天数
	return iDays;
}

// 图片上传

// 图片上传 end
